<!DOCTYPE html>
<html lang="zh">

<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">
</head>
<style>
    .spacing {
        height: 50px;
    }
</style>
<body>
<div id="app">
    <el-container>
        <el-main>
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">订单管理</el-breadcrumb-item>
                <el-breadcrumb-item>收款列表</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>
            <el-row :gutter="20" style="margin-left: 0;margin-right: 0">
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-input placeholder="请输入订单号" v-model="sales_order_no">
                    </el-input>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-input placeholder="请输入下单员" v-model="sales_man">
                    </el-input>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-date-picker
                            v-model="startTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="开始日期" style="width: 100%">
                    </el-date-picker>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-date-picker
                            v-model="endTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="结束日期" style="width: 100%" >
                    </el-date-picker>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-select v-model="payStat" placeholder="请选择订单状态" style="width: 100%">
                        <el-option v-for="item in payStat_list" :key="item.payStat_code"
                                   :label="item.payStat"
                                   :value="item.payStat_code" >
                        </el-option>
                    </el-select>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
                </el-col>
            </el-row>
            <el-table :data="tableData" stripe border style="width:100%" highlight-current-row size="mini" tooltip-effect="dark" height="calc(100vh - 240px)">
                <el-table-column label="序号" align="center" width="50px">
                    　　<template scope="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span></template>
                </el-table-column>
                　　
                <el-table-column prop="orderBill_id" label="订单编号" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                　　
                <el-table-column prop="userGroup_name" label="客户名称" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                <el-table-column prop="user_name" label="下单员" align="center" :show-overflow-tooltip=true>
                    　　
                </el-table-column>
                　　
                <#--<el-table-column prop="order_name" label="订单名称" align="center">-->
                    <#--　　-->
                <#--</el-table-column>-->
                <el-table-column prop="crtTime" label="下单时间" align="center" :show-overflow-tooltip=true>
                </el-table-column>
                <el-table-column v-if prop="price" label="订单金额（元）" align="center" :show-overflow-tooltip=true>
                </el-table-column>
                <el-table-column prop="payAmout" label="收款金额" align="center"
                                  :show-overflow-tooltip=true>
                </el-table-column>
                <el-table-column prop="payStat" label="状态" align="center"
                                 >
                    <template slot-scope="{row}" >
                        <el-tag v-if="row.payStat == 01" type="danger">未确认</el-tag>
                        <el-tag v-else type="success">已确认</el-tag>
                    </template>

                </el-table-column>
                <el-table-column label="操作" align="center" min-width="100" fixed="right">
                    <template slot-scope="scope">
                    <#--等待乙方确认状态-->
                        <el-button type="text" @click="detail(scope.row.payment_pk)">查看</el-button>
                        <el-button type="text"  v-if="scope.row.payStat==01" @click="affirm(scope.row.payment_pk,scope.row.orderBill_id)">确认</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer>
            <el-row >
                <el-col >
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :page-sizes="[100, 500, 1000]" :page-size="pageSize"
                                   layout="total, sizes, prev, pager, next, jumper"
                                   :total="totalRecords" >
                    </el-pagination>
                </el-col>
            </el-row>
        </el-footer>
        <el-dialog title="付款凭证详情" :visible.sync="dialogFormVisible" ref="upload" width="60%">
            <el-form label-width="30%">
                <el-row>
                    <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                        <el-form-item label="订单编号" prop="sales_order_no">
                            <el-input :disabled="true" v-model="sales_order_no"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                        <el-form-item label="付款金额">
                            <el-input :disabled="true" v-model="payAmout">
                            </el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                        <el-form-item label="付款凭据">
                            <el-popover
                                    placement="right"
                                    title=""
                                    trigger="click">
                                <img :src="payVoucher" style="width:800px">
                                <img slot="reference" :src="payVoucher" style="max-width: 100px">
                            </el-popover>
                    </el-form-item>

                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
            </div>
        </el-dialog>
    </el-container>
</div>

<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                dialogFormVisible: false,
                dialogVisible: false,
                dialogImageUrl: '',
                sales_order_no: '',
                sales_order_name: '',
                sales_amount: '',
                tableData: [],
                payVoucher:'',
                payAmout:'',
                currentPage: 1, //当前页
                pageSize: 100, //每页总数
                totalRecords: 0, //总条数
                payStat_list: [{
                    payStat_code: '',
                    payStat: '请选择'
                }, {
                    payStat_code: '01',
                    payStat: '未确认'
                }, {
                    payStat_code: '02',
                    payStat: '已确认'
                }],
                payStat: "",
                time_zones: "",
                sales_order_no: '',
                sales_man: "",
                file: '',
                param: '',
                startTime: '',
                endTime: '',
            };
            show: false

        },

        methods: {
            search() {
                this.currentPage=1;
                this.pageSize=100;
                this.ajaxFunction();
            },
            //查看详情
            detail(id) {
                var bool = false;
                var err = "系统异常";
                var resultData = "";
                $.ajax({
                    url: '/order/gatheringDetail.json',
                    type: 'post',
                    data: {id: id},
                    async: false,
                    dataType: 'json',
                    success: function (result) {
                        if (result.ret) {
                            bool = true;
                            resultData = result.data;
                        } else {
                            err = result.msg;
                        }
                    }
                });
                if (bool) {
                    this.sales_order_no = resultData.orderBill_id;
                    this.payVoucher = resultData.payVoucher;
                    this.payAmout = resultData.payAmout;
                    this.dialogFormVisible = true;
                } else {
                    this.$message({
                        message: err,
                        type: 'error'
                    });
                }
                // window.location.href = "/order/orderDetail.page?orderNo=" + val
            },
            async handleSizeChange(val) {
                this.pageSize = val;
                this.ajaxFunction()
            },
            async handleCurrentChange(val) {
                this.currentPage = val;
                this.ajaxFunction()
            },
            affirm(id,orderBill_id) {
                this.$confirm("请确认已收到付款。", '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var bool = false;
                    var err = "系统异常！";
                    $.ajax({
                        url: '/order/affirmGatheringPrice.json',
                        type: 'post',
                        data: {id: id,orderBill_id:orderBill_id},
                        async: false,
                        dataType: 'json',
                        success: function (result) {
                            if (result.ret) {
                                bool = true;
                            } else {
                                err = result.msg;
                            }
                        }
                    });
                    if (bool) {
                        this.$message({
                            message: "收款成功",
                            type: 'success'
                        });
                        this.search();
                    } else {
                        this.$message({
                            message: err,
                            type: 'error'
                        });
                    }
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });
                });
            },
            ajaxFunction() {
                var page = this.currentPage;
                var limit = this.pageSize;
                var payStat = this.payStat;
                var startTime = this.startTime;
                var endTime = this.endTime;
                var sales_order_no = this.sales_order_no;
                var sales_man = this.sales_man;
                var resultData = [];
                var bool = false;
                var err = "系统异常！";
                $.ajax({
                    url: '/order/gathering.json',
                    type: 'post',
                    data: {
                        orderNo: sales_order_no,
                        userName: sales_man,
                        startTime: startTime,
                        endTime: endTime,
                        payStat: payStat,
                        page: page,
                        limit: limit
                    },
                    async: false,
                    dataType: 'json',
                    success: function (result) {
                        if (result.ret) {
                            bool = true;
                            resultData = result.data;
                        }
                    }
                });
                if (bool) {
                    this.tableData = resultData.list;
                    this.currentPage = resultData.page;
                    this.pageSize = parseInt(resultData.size);
                    this.totalRecords = resultData.total;
                } else {
                    this.$message({
                        message: err,
                        type: 'error'
                    });
                }
                // this.button = resultData.operaButton;
                // var tempVue=this;
                // this.button.forEach(function (ele) {
                //     ele.fn=tempVue[ele.fn]
                // })
            },
        },

        async mounted() {
            this.ajaxFunction();
        }
    })
</script>
</body>

</html>